/*IPROG - NEW - FIN*/
/**
 * RastrearPedidoJS 
 *
 * controls if is necesary call the view 'RastrearPedidoDisplayView' or not.
 * @author commerce
 * */
RastrearPedido ={
		service : [], //only use ajax if the order isn't in this array
       /**
        * Call to the view 'RastrearPedidoDisplayView' only if  not called before.
        * @author commerce
        * */
		getPedido : function(orderId){
			if( this.callToService(orderId)){
			var parameters = {};
			parameters.orderId= orderId;
				dojo.xhrPost({
				    url: 'RastrearPedidoDisplayView',
				    content: parameters,
				    service: this,
				    load: function(data){
					dojo.byId('RastrearPedido-'+orderId).innerHTML = data;
						dojo.toggleClass(dojo.query('#toggle2-rp-'+orderId)[0], 'open');
						RastrearPedido.service.push(orderId);
				  	},
				    error: function(errObj,ioArgs) {
						alert(errObj);
				    }
				});
			}else{
				dojo.toggleClass(dojo.query('#toggle2-rp-'+orderId)[0], 'open');
			}
		},
		/**
		 * Verify if the order with orderId not called before and add this to a local var.
		 * @param orderId orderId to the order that you want show 
		 * @author commerce
		 * */
		callToService : function (orderId){	

			for (var i=0;i<this.service.length;i++)
			{
				if (this.service[i] == orderId){
					return false;
				}
			}
			return true;
		}				
}
/*IPROG - END - FIN*/